package com.xbts.system.domain;

import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xbts.common.annotation.Excel;
import com.xbts.common.core.domain.BaseEntity;
import com.xbts.common.utils.StringUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotEmpty;

/**
 * 代码测试对象 test_table
 *
 * @author xbts
 * @date 2023-06-09
 */
@Data
@ApiModel("代码测试对象")
@TableName("test_table")
public class TestTable extends BaseEntity {
    private static final long serialVersionUID = 1L;


    /**
     * 主键
     */
    @TableId
    private String id;


    /**
     * 用户性别（0男 1女 2未知）
     */
    @Excel(name = "用户性别", readConverterExp = "0=男,1=女,2=未知")
    @ApiModelProperty("用户性别")
    @NotEmpty(message = "用户性别不能为空")
    private String sex;


    /**
     * 姓名
     */
    @Excel(name = "姓名")
    @ApiModelProperty("姓名")
    @NotEmpty(message = "姓名不能为空")
    private String name;


    /**
     * 年龄
     */
    @Excel(name = "年龄")
    @ApiModelProperty("年龄")
    @NotEmpty(message = "年龄不能为空")
    private String age;


    public <T> QueryWrapper<T> queryWrapper() {
        QueryWrapper<T> queryWrapper = new QueryWrapper<>();
        queryWrapper.like(StringUtils.isNotEmpty(sex), "sex", sex);
        queryWrapper.like(StringUtils.isNotEmpty(name), "name", name);
        queryWrapper.like(StringUtils.isNotEmpty(age), "age", age);
        return queryWrapper;
    }
}